<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class model_coordinator extends CI_Model{
    var $table      = "tbl_admin";
    var $state      = "master_state";
    var $primary    = "id_admin";
    var $email      = "username";
    
    public function __construct()
    {
        parent::__construct();
    }
    function get_paged_list($limit = 20, $offset = 0, $order_column='datecreated', $order_type='DSC'){
        if(empty($order_column)||empty($order_type)){
            $this->db->order_by("datecreated",'DSC');	
    	}else{
            $this->db->order_by($order_column,$order_type);
            return $this->db->get($this->table, $limit, $offset);
    	}
    }
    function get_all(){
        $q = $this->db->query("SELECT * FROM `".$this->table."` as A LEFT OUTER JOIN `".$this->state."` as S ON A.state_id = S.state_id");
        return $q->result();
    }
    function save_data($isi){
        if( empty($isi) ) return false;
        if( $this->db->insert($this->table,$isi) ) return true;
        return false;
    }
    function update_data($id,$array){
        if(empty($id) || empty($array)) return FALSE;
        $this->db->where($this->primary,$id);	
        if($this->db->update($this->table,$array)) return TRUE;
        else return FALSE;
    }
    function delete($id){
        if( empty($id) ) return false;
        if($this->db->delete($this->table, array($this->primary => $id))) return true;
        else return false; 
    }
    function cek_op(){
        $q = $this->db->query("SELECT * FROM `oportunity`");
        return $q->num_rows();
    }
    function count_by_email($email){
        $q = $this->db->query("SELECT * FROM `$this->table` WHERE `".$this->email."`='$email'");
        return $q->num_rows();
    }
    function select_by_id($id,$mod = "result"){
        $q = $this->db->query("SELECT * FROM `$this->table` WHERE `".$this->primary."`='".$id."'");
        if(strtolower($mod) == "result") return $q->result();
        else return $q->num_rows();
    }
    function login_check($email,$password){
        $q = $this->db->query("SELECT * FROM `$this->table` WHERE `".$this->email."` = '$email' AND `password` = '$password'");
        if($q->num_rows() > 0)return true;
        else return false;
    }
    function login_select($email){
        $q = $this->db->query("SELECT * FROM `$this->table` WHERE `".$this->email."` = '$email'");
        if($q->num_rows() > 0)return $q->row();
        else return false;
    }
    
}
/* End of file model_member.php */
/* Location: ./application/models/model_member.php */
